#
#  PyobjCMidiAppDelegate.py
#  PyobjCMidi
#

from Foundation import *
from AppKit import *
from PyobjCMidiPlugIn import *

from PyObjCTools import NibClassBuilder

class PyobjCMidiAppDelegate(NibClassBuilder.AutoBaseClass):
   def applicationDidFinishLaunching_(self, sender):
      self._loadMidiObj()
           
   def _testMidi(self, iterations = 1, sleepTime = 0): 
      import time
      for i in xrange(iterations):
         print "sending Midi"
         time.sleep(sleepTime)
         self.MIDISender.testMIDI()
         
   def _loadMidiObj(self):
      self.MIDISender = PyobjCMidiPlugIn.alloc().init()
      if self.MIDISender:
         print "midi plugIn inited"
         if self.MIDISender.plugInLoaded():
            print "midi plugIn LOADED!!!"
         
   def reloadMidiObj_(self): #BUTTON ACTION
      del self.MIDISender
      self._loadMidiObj()
         
   def testMidi_(self): #BUTTON ACTION
      self._testMidi()